package com.wep.fence.controller;

import com.wep.fence.domain.R;
import com.wep.fence.dto.RegionGeom;
import com.wep.fence.service.RegionGeomService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController()
@RequestMapping("/region/geom")
@Tag(name = "行政区划围栏管理")
public class RegionGeomController {

    @Resource
    private RegionGeomService regionGeomService;

    /**
     * @param: regionCode     区域编码
     * @param: geomJsonType   围栏类型:0-不带分界线的围栏, 1-带分线的围栏
     * @author wep
     */
    @Operation(summary = "根据指定区域进行地图绘制")
    @PostMapping("/drawRegionMap")
    public R<String> drawRegionMap(String regionCode, @RequestParam(required = false) Integer geomJsonType) {
        String url = regionGeomService.drawRegionMap(regionCode, geomJsonType);
        return R.ok(url, "地图绘制成功");
    }


    @Operation(summary = "区域编码获取区域围栏对象")
    @GetMapping("/queryGeomByRegionCode")
    public R<RegionGeom> queryGeomByRegionCode(String regionCode, @RequestParam(required = false) Integer geomJsonType) {
        RegionGeom regionGeom = regionGeomService.queryGeomByRegionCode(regionCode, geomJsonType);
        return R.ok(regionGeom);
    }
}
